using System;
using System.Collections.Generic;
using UnityEngine;
using FairyGUI;
namespace Wwo
{
    public class MainMenuView : Window
    {
        private Window m_SecondMenu;

        public MainMenuView()
        {
        }

        protected override void OnInit()
        {
            this.contentPane = UIPackage.CreateObject("WaterWorld", "MainMenu").asCom;
            float y = GRoot.inst.height - this.contentPane.height;
            this.SetXY(0, y);

            GComponent returnBtn = this.contentPane.GetChild("JianZhu").asCom;
            returnBtn.onClick.Add(() =>
            {
                if (GRoot.inst.GetChildIndex(UISets.GetInstance().m_JianZhuView) != -1)
                {
                    if (m_SecondMenu != null)
                    {
                        m_SecondMenu.Hide();
                    }
                    m_SecondMenu = null;
                }
                else
                {
                    if (m_SecondMenu != null)
                    {
                        m_SecondMenu.Hide();
                    }
                    m_SecondMenu = UISets.GetInstance().m_JianZhuView;
                    m_SecondMenu.Show();
                }
            });

            GComponent createBtn = this.contentPane.GetChild("Work").asCom;
            createBtn.onClick.Add(() =>
            {
                if (GRoot.inst.GetChildIndex(UISets.GetInstance().m_WorkMgrView) != -1)
                {
                    if (m_SecondMenu != null)
                    {
                        m_SecondMenu.Hide();
                    }
                    m_SecondMenu = null;
                }
                else
                {
                    if (m_SecondMenu != null)
                    {
                        m_SecondMenu.Hide();
                    }
                    m_SecondMenu = UISets.GetInstance().m_WorkMgrView;
                    m_SecondMenu.Show();
                }
            });

            GComponent yeShengBtn = this.contentPane.GetChild("YeSheng").asCom;
            yeShengBtn.onClick.Add(() =>
            {
                if (GRoot.inst.GetChildIndex(UISets.GetInstance().m_YeShengList) != -1)
                {
                    if (m_SecondMenu != null)
                    {
                        m_SecondMenu.Hide();
                    }
                    m_SecondMenu = null;
                }
                else
                {
                    if (m_SecondMenu != null)
                    {
                        m_SecondMenu.Hide();
                    }
                    m_SecondMenu = UISets.GetInstance().m_YeShengList;
                    m_SecondMenu.Show();
                }
            });

            GComponent sysBtn = this.contentPane.GetChild("SysMenu").asCom;
            sysBtn.onClick.Add(() =>
            {
                if (GRoot.inst.GetChildIndex(UISets.GetInstance().m_SysMenuView) != -1)
                {
                    if (m_SecondMenu != null)
                    {
                        m_SecondMenu.Hide();
                    }
                    m_SecondMenu = null;
                }
                else
                {
                    if (m_SecondMenu != null)
                    {
                        m_SecondMenu.Hide();
                    }
                    m_SecondMenu = UISets.GetInstance().m_SysMenuView;
                    m_SecondMenu.Show();
                }
            });
        }

        override protected void OnShown()
        {
        }
    }
}